%top{
#include "boql.h"
}

%x DSTR 
%x SSTR 
 
%%

"quit"    return -1;

" ";
   /* Keywords */
"class"    return CLASS;
"extends"  return -1;
"change"   return CHANGE;
"string"   return STRING;
"integer"  return INTEGER;
"float"    return FLOAT;
"redefine" return REDEFINE;
"relate"   return RELATE;
"unrelate" return UNRELATE;
"time"     return TIME;
"link"     return LINK;
"delink"   return DELINK;
"get"      return GET;
"add"      return ADD;
"delete"   return DELETE;
"update"   return UPDATE;
"set"      return -1;
"and"      return AND;
"or"       return OR;
"not"      return NOT;
"xor"      return XOR;

  /* Symbols */
\{        return CURLY_LEFT;
\}        return CURLY_RIGHT;
\;        return SEMICOLON;
\,        return COMMA;
"<>"      return NE;
"<="      return LE;
">="      return GE;
"->"      return MG;
"><"      return LG;
"||"      return PP;

\<        return LT;
\>        return GT;
\-        return MINUS;
\|        return -1;
\=        return EQUAL;
\(        return BRACK_LEFT;
\)        return BRACK_RIGHT;
\+        return PLUS;
\%        return MOD;
\/        return SLASH;
\*        return ASTERIK;
\^        return POWER;


   /* Strings */
\"          BEGIN(DSTR);
<DSTR>\"    BEGIN(0);
<DSTR>[^"]* return STRING_DATA;

'           BEGIN(SSTR);
<SSTR>'     BEGIN(0);
<SSTR>[^']* return STRING_DATA;

   /* Numbers */
[0-9]*          return INTEGER_DATA;
[0-9]*\.[0-9]*  return FLOAT_DATA;

   /* Identifiers */
[a-z][0-9a-z]*  return IDENTIFIER;

%%

/* Tokenizer debug code */
/*int main () {
 int token;
 while ((token = yylex()) != QUIT) {
  printf("%d %s", token, yytext);
 }
 return 0;
}*/
